<?php   
  session_start();
  include_once('config_site.php');
  include_once('functions/lang.php');
  include_once('functions/templates.php');

  // Initing general vars [
  $svn = File('.svn/entries');
  DefineLang(); // def lang
  $tpl = new PHPTemplate();
  $tpl->add('svn_revision_number', sprintf("%04d", $svn[3]));
  $tpl->add('lang_label',  getLangLabels($_SESSION['lang']));
  // ]

  // Loading AJAX content [
  if(isset($_GET['ajax'])){
    include_once('functions/ajax.php');
    exit(); // Prevent all rest functional since for now all logic is in functions/ajax.php
  }
  // ]

  // Initing main functional for loading characters data
  include_once('functions/main.php');
  include_once('functions/model.php');
  $character = setCurrentCharacter();
  if($character != ''){
    $character_data = getCharacterData($character);
    if($character_data[0] == 'E065')getHash();
    if(isset($_SESSION['user']['id'])){
      $opponents_data = getOponents($character_data, $_SESSION['user']['settings']['items']/15, $_SESSION['user']['settings']['weak']); // List of oponents
    }else
      $opponents_data = getOponents($character_data); // List of oponents
  }
  // ]

  // Generating main page [
  $tpl->add('character', $character);
  $tpl->add('character_data', $character_data);
  $tpl->add('opponents_data', $opponents_data);
  $tpl->display('header.php');
  $tpl->display('main.php'); 
  // ]
?>

